home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / dvtools / examples / programs / view_merge.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-08  |  3.9 KB  |  143 lines

  1. #ifndef lint
  2. static char SccsId[] = "@(#)view_merge.c    V1.10    3/13/95";
  3. #endif
  4. /*
  5. |    file name - view_merge.c
  6. |
  7. |===================================================================
  8. |
  9. |    This program combines two previously saved views into
  10. |    one larger view.  The flag DS_EXACT_MATCH used in the
  11. |    subroutine TviMergeAddDataSources prevents a data source
  12. |    in the second view from overwriting a data source in the
  13. |    first view with the same name.
  14. |
  15. |    The user can specify the device names and the views to be
  16. |    merged and the output view.
  17. |
  18. |    The defaults are DVDEVICE upper.v, lower.v and merged.v
  19. |
  20. |       The newly created view will be displayed and update until the
  21. |       user "QUITS" with the q-key or the right mouse button.
  22. |
  23. |===================================================================
  24. */
  25. #include "std.h"
  26. #include "dvstd.h"
  27. #include "dvtools.h"
  28. #include "Tfundecl.h"
  29. #include "VOfundecl.h"
  30.  
  31. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  32.                      LPSTR lpCmdLine,  int nCmdShow  )
  33. INT argc;
  34. char **argv; 
  35.  
  36.   /*
  37.    argv[1] - display device   (default DVDEVICE)
  38.    argv[2] - first view file  (default upper.v)
  39.    argv[3] - second view file (default is lower.v)
  40.    argv[4] - new view file    (default is merged.v)
  41.    */
  42.  
  43.   OBJECT screen, location;
  44.   VIEW view, view1, view2;
  45.   DATASOURCELIST masterdsl;
  46.   DRAWPORT drawport;
  47.   int key;
  48.  
  49.   argc = 0;
  50.   /* use value of DVPATH config var */
  51.   make_argv(&argc,&argv,GetCommandLine());
  52.   TInit ((char *) NULL, (char *) NULL);
  53.  
  54.   /* Open the display device */
  55.   if (argc > 1)
  56.     screen = TscOpenSet (argv[1], (char *) NULL,
  57.                          V_X_EXPOSURE_BLOCK, YES, V_END_OF_LIST);
  58.   else
  59.     screen = TscOpenSet ((char *) NULL, (char *) NULL,
  60.                          V_X_EXPOSURE_BLOCK, YES, V_END_OF_LIST);
  61.   if (!screen)
  62.     {
  63.       printf ("Must specify device on command line or");
  64.       printf (" in DataViews configuration file.\n");
  65.       exit (EXIT_ERR);
  66.     }
  67.  
  68.   if (argc > 3)
  69.     {
  70.       /* Load two views and create the new one */
  71.       view1 = TviLoad (argv[2]);
  72.       view2 = TviLoad (argv[3]);
  73.     }
  74.   else
  75.     {
  76.       /* Load two views and create the new one */
  77.       view1 = TviLoad ("upper.v");
  78.       view2 = TviLoad ("lower.v");
  79.     }
  80.  
  81.   view = TviCreate ();
  82.  
  83.   /* Merge the datasources into the new view */
  84.   masterdsl = TviGetDataSourceList (view);
  85.   TviMergeAddDataSources (view1, masterdsl, DS_EXACTMATCH);
  86.   TviMergeAddDataSources (view2, masterdsl, DS_EXACTMATCH);
  87.  
  88.   /* Merge the drawings into the new view */
  89.   TviMergeDrawing (view, TviGetDrawing (view1));
  90.   TviMergeDrawing (view, TviGetDrawing (view2));
  91.  
  92.   /* Display the new view */
  93.   drawport = TdpCreate (screen, view,
  94.                         (RECTANGLE *) NULL, (RECTANGLE *) NULL);
  95.  
  96.   TdlOpenData (masterdsl);
  97.   TdlReadData (masterdsl);
  98.   TdpDraw (drawport);
  99.  
  100.   key = '\n';
  101.   while ((key != 'q') && (key != 3))
  102.     {
  103.       TdlReadData (masterdsl);
  104.       TdpDrawNext (drawport);
  105.       location = TloPoll (PICK_POLL);
  106.       if (location)
  107.         key = VOloKey (location);
  108.     }
  109.  
  110.   /* Save the merged view */
  111.   if (argc > 4)
  112.     {
  113.       TviSave (view, argv[4]);
  114.  
  115.       /* Print success message and exit */
  116.       printf ("File '%s' created - ", argv[4]);
  117.       printf ("use DV-Draw or DV-Play to display.\n");
  118.     }
  119.   else
  120.     {
  121.       TviSave (view, "merged.v");
  122.  
  123.       /* Print success message and exit */
  124.       printf ("File 'merged.v' created - ");
  125.       printf ("use DV-Draw or DV-Play to display.\n");
  126.     }
  127.  
  128.   /*
  129.    *   Erase the screen, free the dynamic data structures, close the
  130.    *     display device, and terminate DV-Tools.
  131.    */
  132.   TscErase (screen);
  133.   TdpDestroy (drawport);
  134.   TdlCloseData (masterdsl);
  135.   TviDestroy (view);
  136.   TviDestroy (view1);
  137.   TviDestroy (view2);
  138.   TscCloseCurrentScreen ();
  139.   TTerminate ();
  140.   return (EXIT_OK);
  141. }
  142.